package demo1;

/**
 * 创建线程方式一，继承Thread方法
 * */

class MyThread extends Thread {
        @Override
        public void run() {//线程入口
            while(true) {
                System.out.println("hello Thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    }
    public class Demo1{
        public static void main(String[] args) throws InterruptedException {
            MyThread myThread=new MyThread();
            myThread.start();
            while (true) {
                System.out.println("hello world");
                Thread.sleep(1000);
            }
        }
    }

